package com.liss.concurrency;

/**
 * @author lisensen
 * @date 2024/9/13
 */
public class InterruptThreadDemo {
    public static void main(String[] args) {
        Thread sleeper = new Thread(()->{
            try{
                System.out.println("县城开始睡眠");
                Thread.sleep(5000);
                System.out.println("睡眠结束");
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("线程被中断");
            }

        },"sleeper");
        sleeper.start();
        try{
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        sleeper.interrupt();
        System.out.println("中断信号已发送，");
    }
}
